/*
 * EvaluatePresenter.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.service.feedback;

import com.yidiandao.business.R;
import com.yidiandao.business.data.model.CommonModel;
import com.yidiandao.business.data.model.ICommonModel;
import com.yidiandao.business.utils.RegexUtils;
import com.yidiandao.business.utils.UIUtils;

/** 评价我们 意见反馈 */
public class FeedbackPresenter implements FeedbackContract.Presenter {

    private final CommonModel mCommonModel;
    private FeedbackContract.View mView;

    public FeedbackPresenter(FeedbackContract.View view) {
        mView = view;
        mView.setPresenter(this);

        mCommonModel = new CommonModel();
    }

    @Override
    public void start() {
        if (!(RegexUtils.checkContent(mView.getConnection())
                || RegexUtils.checkEmail(mView.getConnection())
                || RegexUtils.checkQQ(mView.getConnection()))) {
            UIUtils.showToast(UIUtils.getString(R.string.service_feedback_tip));
            return;
        }
        mView.showDialog();

        mCommonModel.sendFeedBackInfo(
                mView.getPagerTag(),
                mView.getFeedBackInfo(),
                mView.getConnection(),
                new ICommonModel.onAccessNetListener() {
                    @Override
                    public void onSuccess(Object o) {
                        UIUtils.showToast("提交成功，感谢您的反馈");
                        mView.finishActivity();
                    }

                    @Override
                    public void onFailed() {
                    }

                    @Override
                    public void onFinal() {
                        mView.disMissDialog();
                    }
                });
    }
}
